<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
    <title>智慧社区-物业管理</title>

    <meta name="description" content="Dashboard" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/resource/assets/img/favicon.png" type="image/x-icon">

    <link href="${pageContext.request.contextPath}/resource/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/resource/assets/css/font-awesome.min.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/resource/assets/css/beyond.min.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/resource/assets/css/animate.min.css" rel="stylesheet" />
    <link href="${pageContext.request.contextPath}/resource/assets/css/dataTables.bootstrap.css" rel="stylesheet" />
    
    <!--Skin Script: Place this script in head to load scripts for skins and rtl support-->
    <script src="${pageContext.request.contextPath}/resource/assets/js/skins.min.js"></script>

</head>
<body>

<%@include file="../header.jsp" %>
	<!-- Main Container -->
    <div class="main-container container-fluid">
        <!-- Page Container -->
        <div class="page-container">
            <!-- Page Sidebar -->
            <%@include file="../nav.jsp" %><!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb" style="margin-top: 8px;">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="../property.jsp">首页</a>
                        </li>
                        <li>投诉建议</li>
                        <li class="active">投诉记录</li>
                    </ul>
                </div><!-- /Page Breadcrumb -->
                <!-- Page Header -->
                <div class="page-header position-relative">
                    <div class="header-title" style="margin-top: 2px;">
                        <h1>
                            投诉记录
                        </h1>
                    </div><!--Header Buttons-->
                    <div class="header-buttons">
                        <a class="sidebar-toggler" href="#">
                            <i class="fa fa-arrows-h"></i>
                        </a>
                        <a class="refresh" id="refresh-toggler" href="">
                            <i class="glyphicon glyphicon-refresh"></i>
                        </a>
                        <a class="fullscreen" id="fullscreen-toggler" href="#">
                            <i class="glyphicon glyphicon-fullscreen"></i>
                        </a>
                    </div><!--Header Buttons End-->
                </div><!-- /Page Header -->
                <!-- Page Body -->
                <div class="page-body">
                	 <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="widget">
                                <div class="widget-header bordered-bottom bordered-yellow">
                                    <span class="widget-caption">搜索投诉描述</span>
                                    <div class="widget-buttons">
                                        <a href="#" data-toggle="maximize">
                                            <i class="fa fa-expand"></i>
                                        </a>
                                        <a href="#" data-toggle="collapse">
                                            <i class="fa fa-minus"></i>
                                        </a>
                                        <a href="#" data-toggle="dispose">
                                            <i class="fa fa-times"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="widget-body no-padding">
                                    <table class="table table-bordered table-hover table-striped" id="searchable" style="width: 100% !important;">
                                        <thead class="bordered-darkorange">
                                            <tr role="row">
                                                <th>编号</th>
						                        <th>主题</th>
						                        <th>描述</th>
						                        <th>投诉人</th>
						                        <th>联系电话</th>
						                        <th>投诉时间</th>
						                        <th>状态</th>
						                        <th>详情</th>
                                            </tr>
                                        </thead>

                                        <tfoot>
                                            <tr>
                                                <th>编号</th>
						                        <th>主题</th>
						                        <th>描述</th>
						                        <th>投诉人</th>
						                        <th>联系电话</th>
						                        <th>投诉时间</th>
						                        <th>状态</th>
						                        <th>详情</th>
                                            </tr>
                                        </tfoot>
                                        <tbody>
                                          
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div><!-- /Page Body -->
             </div><!-- /Page Content -->
     	</div><!-- /Page Container -->
     </div><!-- /Main Container -->
     	<script src="${pageContext.request.contextPath}/resource/assets/js/jquery-2.0.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/resource/assets/js/bootstrap.min.js"></script>

    <!--Beyond Scripts-->
    <script src="${pageContext.request.contextPath}/resource/assets/js/beyond.min.js"></script>
<script src="${pageContext.request.contextPath}/resource/assets/js/datatable/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/resource/assets/js/datatable/ZeroClipboard.js"></script>
    <script src="${pageContext.request.contextPath}/resource/assets/js/datatable/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript">
    var iRowIndex = 1;
    	$(document).ready(function(){
    		$('#menu_complain').addClass("active open");
    		$('#menu_complainlist').addClass("active");
    		//InitiateSearchableDataTable.init();
    		$('#searchable').dataTable({
                "sDom": "Tflt<'row DTTTFooter'<'col-sm-6'i><'col-sm-6'p>>",
                "aLengthMenu": [
                   [10, 25, 50],
                   [10, 25, 50]
                ],
                "iDisplayLength": 10,
                "oLanguage": {
                    "sLengthMenu": "_MENU_",
                    "sZeroRecords": "对不起，查询不到任何相关数据",
                    "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
                    "sInfoEmpty": "找不到相关数据",
                    "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                    "sProcessing": "正在加载中...",
                    "sSearch": "",
                    "sUrl": "", 
                    "oPaginate": {
                        "sFirst":    " 首页",
                        "sPrevious": " 上一页 ",
                        "sNext":     " 下一页 ",
                        "sLast":     " 末页 "
                    }
                },
                "bStateSave": true,
                "bProcessing": true, 
                "bProcessing": false, 
         		"bServerSide": true,
         		"bSort": false,
         	    "sAjaxSource": "${pageContext.request.contextPath}/complain_list",
         	    "fnServerData": retrieveData, 
         	    "aoColumns":
         	           [  
								{ "mData": "rowIndex",
								  "sDefaultContent" : "",
								  "sWidth":"60px",
								  "mRender": function (data, type, full) {
		         						return iRowIndex++;
		                     		}
								},
								{ "mData": "subject",
									"sDefaultContent" : ""
					        	}, 
					        	{ "mData": "description",
									"sDefaultContent" : ""
					        	}, 
					        	{ "mData": "complainUser",
					        		"sDefaultContent" : "",
					        		"mRender": function (data, type, full) {
					        			if (full.user.name == null) {
											return full.user.username;
										} else {
											return full.user.name;
										}
				            		}	
					        	},
					        	{ "mData": "phoneNumber",
					        		"sDefaultContent" : "",
					        		"mRender": function (data, type, full) {
					        			if (full.user.phoneNumber == null) {
					        				return full.user.username;
										} else {
											return full.user.phoneNumber;
										}
				            		}	
					        	},
					        	{ "mData": "createdAt",
					        		"sDefaultContent" : "",
					        		"mRender": function (data, type, full) {
										return unixToDate(full.createdAt,true,8);
				            		}	
					        	},
					        	{ "mData": "status",
					        		"sDefaultContent" : "",
					        		"mRender": function (data, type, full) {
					        			if (full.status == "0") {
											return "<font style='color:red;'>待处理</font>";
										}else if(full.status == "1"){
											return "<font style='color:green;'>待处中</font>";
										}else{
											return "已处理";
										}
				            		}	
					        	},
					        	
					        	{ "mData": "operate",
					        		"sDefaultContent" : "",
					        		"mRender": function (data, type, full) {
										return "<a href='javascript:void(0);' title='"+full.objectId+"' onclick='showDetail(this)'><i class='fa fa-navicon'></i> 详情</a>";
				            		}	
					        	}
         	            ]
         		
            });
            
    		function retrieveData( sSource,aoData, fnCallback) {
            	iRowIndex = 1;
    			$.ajax({
    				"url" : sSource,
    				"data" : {"aoData":JSON.stringify(aoData)},
    				"type" : 'post',
    				"dataType" : 'json',
    				"success" : function(result) {
    					$('.loading-container').hide();
    					if(result == 201){
    						alert("鉴权已过期，请重新登录");
    						location.href="/WisdomHome";
    						return;
    					}
    					fnCallback(result);
    				},
    				"error" : function(msg) {
    					alert("error msg:"+msg.responseText);
    				}
    			});
    		}
            
    	});
    	
	function showDetail(obj){
    		location.href="${pageContext.request.contextPath}/complain_detail?complainId="+obj.title;
    }
    </script>
</body>
</html>